package com.mscsoft.ui;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundImage;
import javafx.scene.layout.BackgroundPosition;
import javafx.scene.layout.BackgroundRepeat;
import javafx.scene.layout.BackgroundSize;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;

public class Controller {

    @FXML
    private ImageView background;

    @FXML
    private HBox emailBox;

    @FXML
    private ImageView emailImage;

    @FXML
    private Label emailLabel;

    @FXML
    private HBox emailPane;

    @FXML
    private Label forgetpwdLabel;

    @FXML
    private VBox inputBox;

    @FXML
    private Button loginButton;

    @FXML
    private ImageView logoImage;

    @FXML
    private Pane mainPane;

    @FXML
    private ImageView ninImageView;

    @FXML
    private HBox operateBox;

    @FXML
    private HBox othersBox;

    @FXML
    private HBox pwdBox;

    @FXML
    private ImageView pwdImage;

    @FXML
    private Label pwdLabel;

    @FXML
    private HBox pwdPane;

    @FXML
    private Label registeredLabel;

    @FXML
    private VBox textBox;

    @FXML
    private Button offlineButton;

    @FXML
    private Button onlineButton;

    @FXML
    private Button webButton;

    @FXML
    public void initialize() {
        ninImageView.setImage(setNinImage());
        background.setImage(setBackgroundImage());
        emailImage.setImage(setEmailImage());
        pwdImage.setImage(setPwdImage());
        // 登录按钮样式
        Image loginImage = new Image(getClass().getResourceAsStream("/static/img/SceneComponent/loginImage.png"));
        BackgroundImage loginBgImage = new BackgroundImage(loginImage, BackgroundRepeat.NO_REPEAT,
                BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
                new BackgroundSize(loginButton.getWidth(), loginButton.getHeight(), true, true, true, false));
        Background loginBackground = new Background(loginBgImage);
        loginButton.setBackground(loginBackground);
        // 离线模式按钮样式
        Image offlineImage = new Image(getClass().getResourceAsStream("/static/img/SceneComponent/offlineImage.png"));
        BackgroundImage offlineBgImage = new BackgroundImage(offlineImage, BackgroundRepeat.NO_REPEAT,
                BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
                new BackgroundSize(offlineButton.getWidth(), offlineButton.getHeight(), true, true, true, false));
        Background offlineBackground = new Background(offlineBgImage);
        offlineButton.setBackground(offlineBackground);
        // 在线模式按钮样式
        Image onlineImage = new Image(getClass().getResourceAsStream("/static/img/SceneComponent/onlineImage.png"));
        BackgroundImage onlineBgImage = new BackgroundImage(onlineImage, BackgroundRepeat.NO_REPEAT,
                BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
                new BackgroundSize(onlineButton.getWidth(), onlineButton.getHeight(), true, true, true, false));
        Background onlineBackground = new Background(onlineBgImage);
        onlineButton.setBackground(onlineBackground);
        // 下载按钮样式
        Image downloadImage = new Image(getClass().getResourceAsStream("/static/img/SceneComponent/download.png"));
        BackgroundImage downloadBgImage = new BackgroundImage(downloadImage, BackgroundRepeat.NO_REPEAT,
                BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
                new BackgroundSize(webButton.getWidth(), webButton.getHeight(), true, true, true, false));
        Background downloadBackground = new Background(downloadBgImage);
        webButton.setBackground(downloadBackground);
    }

    public Image setNinImage() {
        return new Image(getClass().getResourceAsStream("/static/img/SceneComponent/您.png"));
    }

    public Image setBackgroundImage() {
        return new Image(getClass().getResourceAsStream("/static/img/SceneComponent/backgroundImage.png"));
    }

    public Image setEmailImage() {
        return new Image(getClass().getResourceAsStream("/static/img/SceneComponent/emailImage.png"));
    }

    public Image setPwdImage() {
        return new Image(getClass().getResourceAsStream("/static/img/SceneComponent/pwdImage.png"));
    }
}
